load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//visibility:public"])

rust_library(
    name = "lib",
    srcs = glob(
        ["src/**/*.rs"],
        exclude = ["src/main.rs"],
    ),
    crate_name = "orchestrator",
    proc_macro_deps = [
        # Keep sorted.
        "@crate_index//:async-trait",
        "@crate_index//:indoc",
        "@crate_index//:strum_macros",
    ],
    version = "0.9.0",
    deps = [
        # Keep sorted.
        "//packages/ic-ed25519",
        "//rs/config",
        "//rs/consensus/cup_utils",
        "//rs/consensus/dkg",
        "//rs/crypto",
        "//rs/crypto/node_key_generation",
        "//rs/crypto/tls_interfaces",
        "//rs/http_endpoints/async_utils",
        "//rs/http_endpoints/metrics",
        "//rs/http_utils",
        "//rs/ic_os/guest_upgrade/server",
        "//rs/interfaces",
        "//rs/interfaces/registry",
        "//rs/monitoring/logger",
        "//rs/monitoring/metrics",
        "//rs/nns/constants",
        "//rs/orchestrator/dashboard",
        "//rs/orchestrator/image_upgrader",
        "//rs/orchestrator/registry_replicator",
        "//rs/protobuf",
        "//rs/registry/canister/api",
        "//rs/registry/helpers",
        "//rs/registry/keys",
        "//rs/registry/local_store",
        "//rs/sys",
        "//rs/types/management_canister_types",
        "//rs/types/types",
        "@crate_index//:assert_matches",
        "@crate_index//:backoff",
        "@crate_index//:candid",
        "@crate_index//:clap",
        "@crate_index//:env-file-reader",
        "@crate_index//:exec",
        "@crate_index//:get_if_addrs",
        "@crate_index//:hex",
        "@crate_index//:http-body-util",
        "@crate_index//:hyper",
        "@crate_index//:hyper-rustls",
        "@crate_index//:hyper-util",
        "@crate_index//:ic-agent",
        "@crate_index//:idna",
        "@crate_index//:nix",
        "@crate_index//:prometheus",
        "@crate_index//:prost",
        "@crate_index//:qrcode",
        "@crate_index//:rand",
        "@crate_index//:serde",
        "@crate_index//:serde_cbor",
        "@crate_index//:serde_json",
        "@crate_index//:slog",
        "@crate_index//:slog-async",
        "@crate_index//:strum",
        "@crate_index//:tempfile",
        "@crate_index//:tokio",
        "@crate_index//:tokio-util",
        "@crate_index//:url",
    ],
)

rust_binary(
    name = "orchestrator",
    srcs = ["src/main.rs"],
    deps = [
        # Keep sorted.
        ":lib",
        "//rs/http_endpoints/async_utils",
        "//rs/monitoring/logger",
        "@crate_index//:clap",
        "@crate_index//:slog",
        "@crate_index//:tokio",
        "@crate_index//:tokio-util",
    ],
)

rust_test(
    name = "orchestrator_test",
    compile_data = [
        "testdata/nftables_assigned_replica.conf.golden",
        "testdata/nftables_boundary_node_app_subnet.conf.golden",
        "testdata/nftables_boundary_node_system_subnet.conf.golden",
    ],
    crate = ":lib",
    deps = [
        # Keep sorted.
        "//rs/crypto/temp_crypto",
        "//rs/crypto/test_utils/canister_threshold_sigs",
        "//rs/crypto/test_utils/crypto_returning_ok",
        "//rs/crypto/test_utils/ni-dkg",
        "//rs/crypto/test_utils/reproducible_rng",
        "//rs/crypto/test_utils/tls",
        "//rs/crypto/tls_interfaces/mocks",
        "//rs/ic_os/config:config_lib",
        "//rs/registry/fake",
        "//rs/registry/proto_data_provider",
        "//rs/registry/subnet_type",
        "//rs/test_utilities/consensus",
        "//rs/test_utilities/in_memory_logger",
        "//rs/test_utilities/logger",
        "//rs/test_utilities/registry",
        "//rs/test_utilities/types",
        "@crate_index//:async-stream",
        "@crate_index//:hyper-util",
        "@crate_index//:mockall",
        "@crate_index//:rcgen",
        "@crate_index//:rustls",
        "@crate_index//:tokio-rustls",
    ],
)
